<?php /* 
Owner Yaffare
Client id YKJQWB3KSX3TIC0PTYOXCJ2OZUMJ2I3S45B52FBJUFK0O2FM
Client secret OL5ECMYMSDPW3M54E5YAELPQIPDRDLJ5LVP1QUUSKAA1JKOO

  https://api.foursquare.com/v2/venues/search
  ?client_id=YKJQWB3KSX3TIC0PTYOXCJ2OZUMJ2I3S45B52FBJUFK0O2FM
  &client_secret=OL5ECMYMSDPW3M54E5YAELPQIPDRDLJ5LVP1QUUSKAA1JKOO
  &v=20130815
  &ll=40.7,-74
  &v=20130219
  https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=YKJQWB3KSX3TIC0PTYOXCJ2OZUMJ2I3S45B52FBJUFK0O2FM&client_secret=OL5ECMYMSDPW3M54E5YAELPQIPDRDLJ5LVP1QUUSKAA1JKOO&v=20130219

  
  allow_url_fopen must be enabled for file_get_contents
  */
  $ll= $_POST['ll'];	
$json = file_get_contents("https://api.foursquare.com/v2/venues/search?ll=".$ll."&client_id=YKJQWB3KSX3TIC0PTYOXCJ2OZUMJ2I3S45B52FBJUFK0O2FM&client_secret=OL5ECMYMSDPW3M54E5YAELPQIPDRDLJ5LVP1QUUSKAA1JKOO&v=20130219&limit=2000&verified=false");

//$json = file_get_contents("https://api.foursquare.com/v2/venues/search?ll=40.7,-74&client_id=YKJQWB3KSX3TIC0PTYOXCJ2OZUMJ2I3S45B52FBJUFK0O2FM&client_secret=OL5ECMYMSDPW3M54E5YAELPQIPDRDLJ5LVP1QUUSKAA1JKOO&v=20130219");

$decoded_venueinfo = json_decode($json);
//return $decoded_venueinfo;
	//var_dump($obj);
	$i = 0;
	
	$venues_html="<section data-type='list'>
				  <header>Venues</header>
					  <ul>";
	
foreach ($decoded_venueinfo->response->venues as $result){
	$i++;
	//echo $i.' ';
    //if(isset($result->name)) echo $result->name.'<br>';
    //if(isset($result->id)) echo $result->id.'<br>';
    //if(isset($result->location->address)) echo $result->location->address.'<br>';
    //if(isset($result->location->lat)) echo 'Lat: '.$result->location->lat.'<br>';
    //if(isset($result->location->lng)) echo 'Lng: '.$result->location->lng.'<br>';
    //if(isset($result->location->city)) echo $result->location->city.'<br>';
    //if(isset($result->location->country)) echo $result->location->country.'<br><br><br>';    

		if(isset($result->name)){
			$venues_html.="<li><p>".$result->name."</p></li>";				
		}	
				  	
    } 
			$venues_html.="</ul></section>";
			echo $venues_html; 
 ?>